
<?php
require_once("xforms/Core.php");

class XForms_trigger extends XForms_core {
  protected $tpl = '<div class="xforms_trigger {renderClass} " >{renderAppearance} </div>';
  protected $script = '.append(new XForms_trigger({renderJson}))';

  function renderLabel(){
    return $this->renderChildNodes(array("xforms:label"));
  }
  function renderAppearance(){
    $e = new Evaluator();
    switch($this->node->getAttribute("appearance")) {
      case "minimal":
        $subtpl = '<a href="#" {renderId}>{renderLabel} </a>';
      break;
      case "compact":
        $subtpl = '<button class="xforms_trigger_compact" type="button" {renderId}>{renderLabel}</button>';
      break;
      case "full":
      default:
        $subtpl = '<button type="button" {renderId} >{renderLabel}</button>';
    }
    $result = $e->evaluate($subtpl, $this);
    return $result;
  }
  function renderClass(){
  $cssClass="";
  $binding = $this->getBinding();
  if($binding && $binding->getAttribute("relevant")) {
	$xBinding = $this->getXElement($binding);
    switch($xBinding->evalAttribute("relevant")){
      case true: break;
      case false: $cssClass=$cssClass . " xforms_nonvisible";break;
      default:
    }
  }
  return $cssClass;
  }
}

